import 'package:get/get.dart';
import '../providers/product_provider.dart';
import '../models/product_model.dart';
import '../models/thing_model.dart';

class ProductRepository {
  final ProductProvider _productProvider = Get.find<ProductProvider>();
  
  /// 获取产品列表
  Future<ProductListResponse> getProductList({
    int pageNum = 1,
    int pageSize = 10,
    String? productName,
    String? productKey,
    int? nodeType,
    String? protocolType,
    int? status,
  }) async {
    return await _productProvider.getProductList(
      pageNum: pageNum,
      pageSize: pageSize,
      productName: productName,
      productKey: productKey,
      nodeType: nodeType,
      protocolType: protocolType,
      status: status,
    );
  }
  
  /// 获取产品详情
  Future<ProductDetailResponse> getProductDetail(int productId) async {
    return await _productProvider.getProductDetail(productId);
  }
  
  /// 根据产品标识码获取产品详情
  Future<ProductDetailResponse> getProductByKey(String productKey) async {
    return await _productProvider.getProductByKey(productKey);
  }
  
  /// 获取物模型列表
  Future<ThingModelListResponse> getThingModelList({
    int pageNum = 1,
    int pageSize = 10,
    int? productId,
    String? modelName,
    int? status,
  }) async {
    return await _productProvider.getThingModelList(
      pageNum: pageNum,
      pageSize: pageSize,
      productId: productId,
      modelName: modelName,
      status: status,
    );
  }
  
  /// 获取无物模型的产品列表
  Future<ProductListResponse> getProductsWithoutModel({
    int pageNum = 1,
    int pageSize = 10,
    String? productName,
    String? productKey,
    int? nodeType,
    int? status,
  }) async {
    return await _productProvider.getProductsWithoutModel(
      pageNum: pageNum,
      pageSize: pageSize,
      productName: productName,
      productKey: productKey,
      nodeType: nodeType,
      status: status,
    );
  }
  
  /// 获取主页所需统计数据
  Future<Map<String, int>> getHomeStatistics() async {
    return await _productProvider.getHomeStatistics();
  }
} 